# for loops
# comments and non-active code are included using the #

for i in range(5):
    print i

# python needs indentation! Notice there is not begin-end or {}


sum = 0

# Calculate the sum of 0 through 9 (incl. 9)
for i in range(10):
    sum = sum + i
    print sum

#This will produce an error message since i does not exist outside the loop
#print i

# since sum was defined outside the loop it can be used outside the loop
#print sum

# The same with a while loop
print "Doing the same using a while loop"

# while loop
sum = 0
i = 0

while i < 10:
    sum += i
    print sum
    i += 1


